<%@ page import="cn.medemede.model.UsersBean" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <link href="style.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="join/css/style.css" media="screen" type="text/css" />
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="js/city.js"></script>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

    <style>
        body
        {
            background:
                    radial-gradient(black 15%, transparent 16%) 0 0,
                    radial-gradient(black 15%, transparent 16%) 8px 8px,
                    radial-gradient(rgba(255,255,255,.1) 15%, transparent 20%) 0 1px,
                    radial-gradient(rgba(255,255,255,.1) 15%, transparent 20%) 8px 9px;
            background-color:#282828;
            background-size:16px 16px;

        }
    </style>

    <title>修改账户</title>
</head>
<body style="padding-top: 70px">
<%  request.setCharacterEncoding("utf-8");
    response.setContentType("text/html;charset=UTF-8");
    UsersBean user= (UsersBean) session.getAttribute("user");
%>
<nav class="navbar navbar-default navbar-fixed-top">
    <div class="container-fluid" style="padding:0 30%">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
            </button>
            <a class="navbar-brand" href="index.jsp"><strong>学生信息管理系统</strong></a>
        </div>
        <div class="navbar-right">
            <p class="navbar-text">【<%=user.getCharacter()%>】 <a href="log_suc.jsp" class="navbar-link"><%=user.getZname()%></a></p>
            <button type="button" class="btn btn-default navbar-btn " onclick="check()">注销</button>
        </div>
    </div>
</nav>

<div style="margin:100px auto;width: 560px">
    <form class="form-horizontal">
        <fieldset>
            <div id="legend" style="text-align:center">
                <legend class="">修改信息</legend>
            </div>
            <div class="control-group">

                <!-- Text input-->
                <label class="col-sm-2 control-label" for="username">用户名</label>
                <div class="col-sm-10 controls">
                    <input id="username" name="username" type="text" placeholder="" class="input-xlarge" value="<%=user
                .getUsername()%>">
                    <p class="help-block"></p>
                </div>
            </div>

            <div class="control-group">

                <!-- Text input-->
                <label class="col-sm-2 control-label" for="zname">姓名</label>
                <div class="col-sm-10 controls">
                    <input type="text" placeholder="" id="zname" name="zname" class="input-xlarge" value="<%=user.getZname()%>">
                    <p class="help-block"></p>
                </div>
            </div>



            <iframe id="tmp_downloadhelper_iframe" style="display: none;"></iframe><div class="control-group">
            <label class="col-sm-2 control-label">性别</label>
            <div class="col-sm-10 controls" style="text-align:center" >
                <!-- Inline Radios -->
                <label class="radio-inline" >
                    <input type="radio" value="男" name="sex" checked="checked">
                    男
                </label>
                <label class="radio-inline">
                    <input type="radio" value="女" name="sex">
                    女
                </label>
            </div>
        </div>

            <div class="control-group">

                <!-- Text input-->
                <label class="col-sm-2 control-label" for="borth">出生日期</label>
                <div class="col-sm-10 controls">
                    <input type="date" placeholder=""  class="input-xlarge" id="borth" name="borth" value="<%=user.getBorth()%>">
                    <p class="help-block"></p>
                </div>
            </div>

            <div class="control-group">

                <!-- Text input-->
                <label class="col-sm-2 control-label" for="phone">联系方式</label>
                <div class="col-sm-10 controls">
                    <input type="text" placeholder="" class="input-xlarge" id="phone" name="phone" value="<%=user.getPhone()%>">
                    <p class="help-block"></p>
                </div>
            </div>

            <div class="control-group">

                <!-- Text input-->
                <label class="col-sm-2 control-label" for="email">Email</label>
                <div class="col-sm-10 controls">
                    <input type="text" placeholder="" class="input-xlarge" id="email" name="email" value="<%=user.getEmail()%>">
                    <p class="help-block"></p>
                </div>
            </div>

            <div class="control-group">

                <!-- Text input-->
                <label class="col-sm-2 control-label" for="province">地区</label>
                <div class="col-sm-10 controls">
                    <!--<input type="text" placeholder="" class="input-xlarge" id="province" name="province">
                    <p class="help-block"></p>-->
                    <label for="province"></label><select id="province" runat="server" onchange="selectprovince(this);" style=" width:95px;" name="province">
                </select>
                    <label for="city"></label><select id="city" runat="server" style=" width:95px;" name="city">
                </select>
                </div>
            </div>

            <div class="control-group">
                <label class="col-sm-2 control-label">爱好</label>

                <!-- Multiple Checkboxes -->
                <div class="col-sm-10 controls" style="text-align:center">
                    <!-- Inline Checkboxes -->
                    <label class="checkbox-inline">
                        <input type="checkbox" value="读书" name="favorite">
                        读书
                    </label>
                    <label class="checkbox-inline">
                        <input type="checkbox" value="上网" name="favorite">
                        上网
                    </label>
                    <label class="checkbox-inline">
                        <input type="checkbox" value="打游戏" name="favorite">
                        打游戏
                    </label>
                    <label class="checkbox-inline">
                        <input type="checkbox" value="听歌" name="favorite">
                        听歌
                    </label>
                    <label class="checkbox-inline">
                        <input type="checkbox" value="看电影" name="favorite">
                        看电影
                    </label>
                    <label class="checkbox-inline">
                        <input type="checkbox" value="动漫" name="favorite">
                        动漫
                    </label>
                    <label class="checkbox-inline">
                        <input type="checkbox" value="技术宅" name="favorite">
                        技术宅
                    </label>
                    <label class="checkbox-inline">
                        <input type="checkbox" value="打代码" name="favorite">
                        打代码
                    </label>
                </div>

            </div>

            <div class="control-group">

                <!-- Text input-->
                <label class="col-sm-2 control-label" for="old_password">原密码</label>
                <div class="col-sm-10 controls">
                    <input type="password" id="old_password" name="old_password" class="input-xlarge">
                    <p class="help-block"></p>
                </div>
            </div>

            <div class="control-group">

                <!-- Text input-->
                <label class="col-sm-2 control-label" for="newpassword">新密码</label>
                <div class="col-sm-10 controls">
                    <input type="password" id="newpassword" name="new_password" class="input-xlarge">
                    <p class="help-block"></p>
                </div>
            </div>

            <div class="control-group">
                <label class="control-label"></label>

                <!-- Button -->
                <div class="controls" style="text-align:center">
                    <button class="btn btn-info" onclick="change()">提交</button>
                </div>
            </div>
            <input type="hidden" name="actionName" value="Do_change">
        </fieldset>
    </form>
</div>

<script>
    function change() {
        var username = $("#username").val();
        var password = $("#newpassword").val();
        if (username !== null && username.length > 2) {
            if (password !== null && password.length > 4) {
                $.ajax({
                    url: "/javaweb/JServlet",
                    type: "POST",
                    dataType:"text",
                    contentType: "application/x-www-form-urlencoded; charset=utf-8",
                    data: $("#myform").serialize(),
                    success:function (data,status) {
                        alert("数据发送状态："+status+"\n"+data);
                    }
                });
            } else {
                $("#passwordBox").text("密码不得少于5位");
            }
        } else {
            $("#usernameBox").text("用户名不得少于3位");
        }
    }

    $("#username").click(function () {
        $("#usernameBox").text("");
    });
    $("#newpassword").click(function () {
        $("#passwordBox").text("");
    });

    function check() {
        if (confirm("注销?")){
            $.post("/javaweb/JServlet",{
                    actionName:"clear"},
                function (data) {
                    if (data.search("clearSuc")!==-1){
                        window.location.href="index.jsp";
                    }else {
                        alert("对不起，注销失败！请重试。");
                    }
                }
            );
        }
    }
</script>

<script type="text/javascript">
    getCity();
</script>
</body>
</html>